import 'package:xvideos/hj_model/home/collection_resp.dart';
import 'package:xvideos/hj_model/home/module_detail_model.dart';
import 'package:xvideos/hj_model/video_model.dart';

//注意⚠️ VideoListResp 用于因兼容不同字段名的视频列表数据
//注意⚠️ 兼容因为不同业务服务端返回的视频列表数据的key不一样，
//注意⚠️ 请勿添加其他类型的数据list，如需添加请单独另外创建新的类
class VideoListResp {
  List<VideoModel>? videos;
  bool? hasNext;
  OriginalBloggerInfo? bloggerInfo;
  String? tagID;
  bool? collected;
  AllSection? section;
  CollectionModel? info;
  List<VideoModel>? tagVidList; // 搜索返回的标签视频
  List<TagsBean>? tags;
  VideoListResp.fromJson(Map<String, dynamic>? json) {
    json ??= {};
    hasNext = json['hasNext'];
    if (json['info'] is Map) {
      info = CollectionModel.fromJson(json['info']);
    }
    if (json['videos'] is List) {
      videos = (json['videos'] as List).map((e) => VideoModel.fromJson(e)).toList();
    }
    if (json['searchVideo'] is List) {
      videos = (json['searchVideo'] as List).map((e) => VideoModel.fromJson(e)).toList();
    }
    if (json['list'] is List) {
      videos = (json['list'] as List).map((e) => VideoModel.fromJson(e)).toList();
    }
    if (json['data'] is List) {
      videos = (json['data'] as List).map((e) => VideoModel.fromJson(e)).toList();
    }
    if (json['searchTag'] is List) {
      videos = (json['searchTag'] as List).map((e) => VideoModel.fromJson(e)).toList();
    }

    tagID = json['tagID'] ?? json['libraryTag']?['id'];
    collected = json['collected'];
    bloggerInfo = OriginalBloggerInfo.fromJson(json["originalBloggerInfo"]);
    if (json['section'] is Map) {
      section = AllSection.fromJson(json['section'] ?? {});
    }
    if (json['tagVidList'] is List) {
      tagVidList = (json['tagVidList'] as List).map((e) => VideoModel.fromJson(e)).toList();
    }
    if (json['tags'] is List) {
      tags = (json['tags'] as List).map((e) => TagsBean.fromMap(e)).toList();
    }
  }
}

class SectionListResp {
  List<AllSection>? list;
  bool? hasNext;

  SectionListResp.fromJson(Map<String, dynamic>? json) {
    json ??= {};
    hasNext = json['hasNext'];
    if (json['list'] is List) {
      list = (json['list'] as List).map((e) => AllSection.fromJson(e)).toList();
    }
  }
}

class OriginalBloggerInfo {
  int? uid;
  String? name;
  String? portrait;
  bool? officialCert;
  String? summary;

  OriginalBloggerInfo();

  OriginalBloggerInfo.fromJson(Map<String, dynamic>? json) {
    json ??= {};
    uid = json['uid'];
    name = json['name'];
    portrait = json['portrait'];
    officialCert = json['officialCert'];
    summary = json['summary'];
  }
}
